package com.aaron.Caitlyn.webapp.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aaron.Caitlyn.system.pojo.BdDataDictionary;
import com.aaron.Caitlyn.system.service.DataDictionaryService;


/**
 * 数据字典管理
 * @author Aaron
 *
 */
@Controller
@RequestMapping("DataDictionary")
public class DataDictionaryController {
	
	@Autowired
	private DataDictionaryService dataDictionaryService;
	
	/**
	 * 跳转到数据字典管理页面
	 * @return
	 */
	@RequestMapping("start")
	public String start(){
		return "BasicDataManagement/DataDictionary/DataDictionaryList";
	}
	
	/**
	 * 查询数据字典的数据
	 */
	@RequestMapping("selectAllDictionary")
	@ResponseBody
	public List<BdDataDictionary> selectAllDictionary(){
		List<BdDataDictionary> dictionaries = dataDictionaryService.selectAllDictionary();
		return dictionaries;
	}
	
	/**
	 * 
	 * 方法功能说明：新增，修改字典数据
	 * 创建：2016年4月13日 by Aaron 
	 * 修改：日期 by 修改者
	 * 修改内容：
	 * @参数： @param dictionary
	 * @参数： @return    
	 * @return int   
	 * @throws
	 */
	@RequestMapping("insertDictionary")
	@ResponseBody
	public int insertDictionary(BdDataDictionary dictionary){
		int result = dataDictionaryService.insertDictionary(dictionary);
		return result;
	}
	/**
	 * 删除数据字典（逻辑删除）
	 */
	@RequestMapping("deleteDictionary")
	@ResponseBody
	public int deleteDictionary(String pid){
		System.out.println(pid);
		int result = 1;
		result = dataDictionaryService.deleteDictionary(pid);
		return result;
	}
}
